package com.easemob.helpdesk.widget.popupwindow;


import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Color;
import android.graphics.drawable.ColorDrawable;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.RelativeLayout;

import com.easemob.helpdesk.utils.CommonUtils;
import com.easemob.helpdesk.widget.pickerview.SimplePickerView;
import com.housekeeperapp.R;

/**
 * Created by wsj on 2018/3/26.
 */

public class VillageFilterWindow extends BasePopupWindow {
    private Context mContext;
    private SimplePickerView simplePickerView;
    private static final String[] channelStrings = {"全部渠道", "网页", "APP", "微信", "微博"};

    public VillageFilterWindow(Context context) {
        this.mContext = context;
        @SuppressLint("InflateParams")
        View contentView = LayoutInflater.from(context).inflate(R.layout.popup_village_filter, null);

        this.setContentView(contentView);
        this.setWidth(ViewGroup.LayoutParams.MATCH_PARENT);
        this.setHeight(ViewGroup.LayoutParams.MATCH_PARENT);
        this.setFocusable(true);
        setOutsideTouchable(true);
        this.update();
        ColorDrawable cDraw = new ColorDrawable(Color.argb(127, 0, 0, 0));
        this.setBackgroundDrawable(cDraw);

//        contentView.findViewById()
        RelativeLayout rl_building = (RelativeLayout) contentView.findViewById(R.id.rl_building);
        RelativeLayout rl_unit = (RelativeLayout) contentView.findViewById(R.id.rl_unit);
        RelativeLayout rl_room = (RelativeLayout) contentView.findViewById(R.id.rl_room);

        rl_building.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
//                simplePickerView = new SimplePickerView(mContext, channelStrings);
//                simplePickerView.setCancelable(true);
//                simplePickerView.show();
            }
        });
    }


    public void showPopupWindow(View parent) {
        if (!this.isShowing()) {
            try{
                this.showAtLocation(parent, 1, CommonUtils.convertDip2Px(mContext, 0), CommonUtils.convertDip2Px(mContext, -64));
            }catch (IllegalStateException e){
                this.dismiss();
            }
        } else {
            this.dismiss();
        }
    }
}
